﻿#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


//逆序打印⼀个整数的每⼀位
void Fun(int n)
{
	while (n>0)
	{
		printf("%d", n % 10);
		n /= 10;
	}

 }

int  main1()
{
	int n = 0; 
	scanf("%d", &n);
	Fun(n);



	return 0; 
}


void  Print(int n)
{
	if (n > 9)
		Print(n / 10);
	printf("%d ", n % 10);//调用完后才打印
}
int main4()
{
	int n = 0;
	scanf("%d", &n);
	Print(n);
	return 0;
}


int FUNC(int n)
{
	int i = 0; 
	int ret = 1;
	for (i = 1; i <= n; i++)
	{

		ret *= i;

	}
	return ret;

 }
int main3()
{
	int n = 0; 
	scanf("%d", &n);
	int r =FUNC(n);
	printf("%d ", r);


	return 0; 
}
//斐波那契数列

int Fib(int n)
{
	int count = 0;
	if (n == 1 || n == 0)
		return 1;
	else
		 return Fib(n-2) + Fib(n - 1);

 }

int main6()
{
	int n = 0; 
	scanf("%d", &n);
	int r = Fib(n);
	printf("%d ", r);



	return 0; 
}
int Fib1(int n )
{
	int a = 1;
	int b = 1;
	int c = 1;
	while (n > 2)
	{
		c = a + b;
		a = b;
		b = c;
		n--;
	}

	return c; 
 }
int main7()
{
	int n = 0;
	scanf("%d", &n);
	int r = Fib1(n);
	printf("%d ", r);


}
int main8()
{
	int a = 1;
	int  b = -1;
	// 1000 0001
	// 1111 1110
	// 1111 1111
	// 0000 0001 
	//10000 0000  1就会被丢掉  说明计算的是补码
	printf("%d", a + b);


	return 0; 
}

int  main9()
{
	int a = 10;
	a = a << 1; //左边抛弃 ，右边填0
	//000 10100
	int b = -1;
	b = b << 1;
	//1000 0001
	//1111 1110
	//1111 1111
	//1111 1110   计算的是 补码
	//1000 0001
	//1000 0010

	printf("%d\n", a);
	printf("%d\n", b);


	int c = 10;
	c = c >> 1;
	//0000 1010
	//0000 0101
	printf("%d\n", c);
	int d = -2;
	d = d >> 1;
	//1000 0010
	//1111 1101
	//1111 1110
	//1111 1111
	//1000 0000
	//1000 0001

	printf("%d ", d);
	return 0; 
}

int main0()
{
	int a = 10;
	//0000 1010
	int b = 9;
	//0000 1001
	//0000 1010
	//0000 1011
	printf("%d\n", a | b); //11
	//0000 1001
	//0000 1010
	//0000 1000
	printf("%d\n ", a & b); //8
	
	//0000 1010
	//0000 1001
	//0000 0011
	printf("%d ", a ^ b);//3 



	return 0; 
}

//不使用第三个变量交换数据
int main()
{
	int  a = 10;
	int b = 20;

	a = a ^ b;
	//0000 1010
	//0001 0100
	//0001 1110  30  
	b = a ^ b;
	//0001 1110
	//0001 0100
	//0000 1010  10
	a = a ^ b;
	//0001 1110   30 
	//0000 1010    10
	//0001 0100    20

	printf("%d %d ", a, b); //20 ,10

}

